#include <stdio.h>
int getReal(char* raw);
int transform(char c);
void quickSort(int *realNumbers,int left, int right);
void printList(int *realNumbers,int size);
int main(){
	int size;
	scanf("%d",&size);
	int* realNumbers = new int[size];
	for(int i=0;i<size;i++){
		char* input = new char[20];
		scanf("%s",input);
		realNumbers[i]=getReal(input);
	}
	quickSort(realNumbers,0,size-1);
	printList(realNumbers,size);
}

int getReal(char* raw){
	int temp=0;
	for(int i=0;raw[i]!='\0';i++){
		int single=-1;
		if(raw[i]>='0'&&raw[i]<='9'){
			single = raw[i]-'0';
		}else if(raw[i]>='A'&&raw[i]<='Y'&&raw[i]!='Q'){
			single = transform(raw[i]); 
		}
		if(single!=-1)
			temp=temp*10+single;
	}
	return temp;
}

int transform(char c){
	if(c>='A'&&c<='P')
		return (c-'A')/3+2;
	if(c>='R'&&c<='Y')
		return (c-'Q')/3+7;
	return -1;
}

void quickSort(int *realNumbers,int left, int right){
	if(left>=right)
		return;

	int pivot = left, tempLeft= left, tempRight= right;
	int pivotNum = realNumbers[pivot];
	while(tempLeft<tempRight){

		while (tempLeft<tempRight&&pivotNum<=realNumbers[tempRight])
			tempRight--;

		realNumbers[pivot]=realNumbers[tempRight];
		realNumbers[tempRight]=pivotNum;
		pivot = tempRight;

		while (tempLeft<tempRight&&pivotNum>=realNumbers[tempLeft])
			tempLeft++;

		realNumbers[pivot]=realNumbers[tempLeft];
		realNumbers[tempLeft]=pivotNum;
		pivot = tempLeft;
	}
	quickSort(realNumbers,left,pivot-1);
	quickSort(realNumbers,pivot+1,right);
}

void printList(int *realNumbers,int size){
	bool printNone=true;
	int current=realNumbers[0],quantity=1;
	for (int i=0;i<size-1;i++)
	{
		if (realNumbers[i]!=realNumbers[i+1])
		{
			if(quantity>1){
				printNone=false;
				printf("%03d-%04d %d\n",current/10000,current%10000,quantity);
			}
			quantity=1;
			current=realNumbers[i+1];
		}else{
			quantity++;
		}
		if(i==size-2&&quantity>1){
			printNone=false;
			printf("%03d-%04d %d\n",current/10000,current%10000,quantity);
		}
	}
	if(printNone)
		printf("No duplicates.\n");
}